#-*- coding:utf-8 -*-
import binascii
import time
from module.ksw import Ksw
from module.store import Store
import sys
complete=[]

def main():
     try:
          time.sleep(5)
          Ksw.getListFromAll()
     except Exception:
          print(Exception)
          main()
     finally:
          print("重启成功")
     # # ls= Ksw.getlist('http://m.00ksw.org/html/3/3479/all.html')
     # ls= Ksw.getlist('http://m.00ksw.org/html/1/3261/all.html')
     # # 开4个 worker，没有参数时默认是 cpu 的核心数  
     # pool = ThreadPool(500)  
     # pool.map(handle, ls)  
     # pool.close()  
     # pool.join()  
     

     
     # 写一个方法 传入url 下载正本电子书
     
   


def handle(dictionary):
     categoryList=dictionary['categoryList']
     hrefList=dictionary['hrefList']
     array_length = len(category)
     # ls= Ksw.getlist(url)
     # # 开4个 worker，没有参数时默认是 cpu 的核心数  
     # pool = ThreadPool(500)  
     # pool.map(handle, ls)  
     # pool.close()  
     # pool.join()  
     # print("执行结束")
     for x in array_length:
        print(hrefList[i]+"次数AAAAAAAAAAAAAAAA："+x)

def handleA(url):
     info= Ksw.getcontent(url)
     name= binascii.crc32(info["content"].encode())
     with open("./resource/%s.txt" % name ,"w",encoding='utf-8') as f:
         f.write(info["content"])
    # 完成任务添加到列表
     complete.append( (info["title"],name) )
     print("%s-----抓取完毕"%info["title"])
    
   # ls=Ksw.getcontent('http://m.00ksw.org/html/3/3479/1495982.html')
   # print(ls)



        

    

if(__name__=="__main__"):
          main()

